package com.job.sun.HomeWork0718;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * @author 张春阳
 * @version 1.0
 * @since 2022-07-19 14:03:58
 */
public class Lottery {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //建立数组存放数据
        int[][] nums = new int[5][7];
        int[] num = new int[]{33, 6, 5, 8, 5, 9, 8};
        //建立随机对象
        //   answer(num);
        Random random = new Random();
        //遍历 将 数组填满
        for (int i = 0; i < 5; i++) {
            int counts=0;
            while (counts <7) {
                int ran = random.nextInt(33) + 1;
                //判断数值是否是第一次出现
                if (choose(ran, counts, i, nums)) {
                    nums[i][counts] = ran;
                    counts++;
                }
            }


        }
        for (int j = 0; j < 5; j++) {
            int gains = gains(nums, j, num);
            String string = Arrays.toString(nums[j]);
            System.out.println(string);
            System.out.println("恭喜获得" + gains + "等奖");
        }


    }

    private static boolean choose(int ran, int m, int r, int[][] nums) {
        for (int j = 0; j < m; j++) {
            if (m != 0 && nums[r][j] == ran) {
                return false;

            }

        }
        return true;
    }

    public static int gains(int[][] nums, int r, int[] num) {
        int count = 0;
        for (int i = 0; i < nums.length+2; i++) {
            if (nums[r][i] == num[i]) {
                ++count;
            }
        }
        return count;
    }

    private static void answer(int[] num) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入正确答案");
        for (int i = 0; i < 7; i++) {
            int anInt = sc.nextInt();
            num[i] = anInt;

        }

    }

    private static void reward(int g, int[][] nums) {
        System.out.println(Arrays.toString(nums));


    }

}